package day230515;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/5/15 9:01
 * 求和
 */
public class Main01 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            int n = scan.nextInt();
            int m = scan.nextInt();
            // 获取 1 + ... +  = m 的组合
            dfs(new ArrayList<>(), 1, n, m, 0);
        }
        scan.close();
    }

    // 深搜思路获取求和的排列
    private static void dfs(ArrayList<Integer> curRes, int pos, int n, int m, int curSum) {
        if (curSum > m) {
            return;
        }
        if (curSum == m) {
            // 打印结果
            for (Integer item : curRes) {
                System.out.print(item + " ");
            }
            System.out.println();
            return;
        }
        // 遍历深搜
        for (int i = pos; i <= n; i++) {
            curRes.add(i);
            dfs(curRes, i + 1, n, m, curSum + i);
            // 回退
            curRes.remove(curRes.size() - 1);
        }
    }
}
